//
//  BFBusinessAuthorServices.m
//  BFoodSystem
//
//  Created by 浙江择富 on 2018/1/19.
//  Copyright © 2018年 陈名正. All rights reserved.
//

#import "BFBusinessAuthorServices.h"

@implementation BFBusinessAuthorServices

/**
提交商户信息
 
 @param truename 真实名字
 @param merchantName 商户简称
 @param sfznumber 身份证号
 @param address 地址
 @param license 营业执照号
 @param blank_number 银行卡号
 @param blank_name 开户姓名
 @param blank_address 开户行
 @param phone 手机号
 @param mail 邮箱
 @param success 成功回调
 @param errCode 错误信息回调
 @param failure 失败回调
 */

- (void)postMerchatInfoWithTruename:(NSString *)truename merchantName:(NSString *)merchantName sfznumber:(NSString *)sfznumber address:(NSString *)address license:(NSString *)license blank_number:(NSString *)blank_number blank_name:(NSString *)blank_name blank_address:(NSString *)blank_address phone:(NSString *)phone mail:(NSString *)mail SuccessBlock:(RequestSuccessBlock)success errorCode:(RequestErrorCodeBlock)errCode Failure:(RequestFailureBlock)failure{
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:[BFUserSignelton shareBFUserSignelton].token forKey:@"token"];
    
    [dic setObject:truename forKey:@"truename"];
    [dic setObject:merchantName forKey:@"merchantName"];
    [dic setObject:sfznumber forKey:@"sfznumber"];
    [dic setObject:address forKey:@"address"];
    [dic setObject:license forKey:@"license"];
    [dic setObject:blank_number forKey:@"blank_number"];
    [dic setObject:blank_name forKey:@"blank_name"];
    [dic setObject:blank_address forKey:@"blank_address"];
    [dic setObject:phone forKey:@"phone"];
    [dic setObject:mail forKey:@"mail"];
    
    NSString *url = [NSString stringWithFormat:@"%@%@",BaseURL,@"/MerchantInfo/add"];
//    BFLog(@" url=%@\n dic = %@", url, dic);
    NSMutableURLRequest *request = [BFYBaseNetTool dealRequset:url dataDic:dic];
    [BFYBaseNetTool postRequest:request params:dic success:^(id responseObject, NSURLResponse *response) {
//        BFLog(@"保存商户信息====%@", responseObject);
        NSDictionary *dataDic = (NSDictionary *)responseObject;
        if ([[dataDic objectForKey:@"code"] integerValue] == 0) {
            success(responseObject[@"msg"]);
        }else{
            NSInteger code = [[dataDic objectForKey:@"code"] integerValue];
            NSString *errorMsg = [dataDic objectForKey:@"msg"];
            errCode(code,errorMsg);
        }
        
    } failure:^(NSError *error) {
        failure(error);
    }];
    
    
}
@end
